//
// Copyright (c) 2011, Peter Lane
// Licensed under the Academic Free License version 3.0

package fan.swtChartWrapper;

import fan.fwt.*;
import fan.gfx.Color;
import fan.sys.*;
import org.eclipse.swtchart.IErrorBar;
import org.eclipse.swtchart.IErrorBar.ErrorBarType;

public class ErrorBarPeer {
  private IErrorBar _errorBar = null;

  public static ErrorBarPeer make (fan.swtChartWrapper.ErrorBar self) throws Exception {
    return new ErrorBarPeer ();
  }

  public void setIErrorBar (IErrorBar errorBar) {
    _errorBar = errorBar;
    _errorBar.setColor (Fwt.get().color (_colour));
    _errorBar.setLineWidth ((int)_lineWidth);
    _errorBar.setVisible (_visible);
    if (_minusErrors != null) _errorBar.setMinusErrors (Utility.toDoubleArray (_minusErrors));
    if (_plusErrors != null) _errorBar.setPlusErrors (Utility.toDoubleArray (_plusErrors));
    _errorBar.setType (Utility.toSwt (_type));
  }

  private Color _colour = Color.black;
  public Color color (fan.swtChartWrapper.ErrorBar self) { return _colour; }
  public void color (fan.swtChartWrapper.ErrorBar self, Color v) {
    _colour = v;
    if (_errorBar != null) _errorBar.setColor (Fwt.get().color (_colour));
  }

  private long _lineWidth = 1;
  public long lineWidth (fan.swtChartWrapper.ErrorBar self) { return _lineWidth; }
  public void lineWidth (fan.swtChartWrapper.ErrorBar self, long v) {
    _lineWidth = v;
    if (_errorBar != null) _errorBar.setLineWidth ((int)_lineWidth);
  }

  private boolean _visible = false;
  public boolean visible (fan.swtChartWrapper.ErrorBar self) { return _visible; }
  public void visible (fan.swtChartWrapper.ErrorBar self, boolean v) {
    _visible = v;
    if (_errorBar != null) _errorBar.setVisible (_visible);
  }

  private List _minusErrors = null;
  public List minusErrors (fan.swtChartWrapper.ErrorBar self) { return _minusErrors; }
  public void minusErrors (fan.swtChartWrapper.ErrorBar self, List errors) {
    _minusErrors = errors.dup ();
    if (_errorBar != null) _errorBar.setMinusErrors (Utility.toDoubleArray (_minusErrors));
  }

  private List _plusErrors = null;
  public List plusErrors (fan.swtChartWrapper.ErrorBar self) { return _plusErrors; }
  public void plusErrors (fan.swtChartWrapper.ErrorBar self, List errors) {
    _plusErrors = errors.dup ();
    if (_errorBar != null) _errorBar.setPlusErrors (Utility.toDoubleArray (_plusErrors));
  }

  private fan.swtChartWrapper.ErrorBarType _type = fan.swtChartWrapper.ErrorBarType.both;
  public fan.swtChartWrapper.ErrorBarType type (fan.swtChartWrapper.ErrorBar self) { return _type; }
  public void type (fan.swtChartWrapper.ErrorBar self, fan.swtChartWrapper.ErrorBarType v) {
    _type = v;
    if (_errorBar != null) _errorBar.setType (Utility.toSwt (_type));
  }



}
